package com.ayu.envdemo.kafka;

import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

/**
 * @Author 徐林玉
 * @Description SimpleConsumer
 * @Date 2023/2/20 14:32
 * @Version 1.0
 */

@Component
@Slf4j
public class SimpleConsumer {

    /**
     * 简单消费
     * @param record record
     */
    @KafkaListener(topics = {"tb-devices"})
    public void onMessage(ConsumerRecord<?, ?> record){
        // 消费的哪个topic、partition的消息,打印出消息内容
        log.warn("简单消费："+record.topic()+"-"+record.partition()+"-"+record.value());
    }

}
